﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business.IManager;
using Business.Manager;
using System.Data;
using Utility;
using Entity;

namespace OnlinePayment.Home
{
    public partial class GuestbookList : System.Web.UI.Page
    {
        IGuestbookManager guestbookManager = new GuestbookManager();
        public DataTable dt;
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack){
                dataBind();

            }
        }
        


        private void dataBind()
        {
            dt = guestbookManager.getTable();
            gbrpt.DataSource = dt;
            gbrpt.DataBind();
            /*paging
            PagedDataSource pds = new PagedDataSource();
            pds.DataSource = dt.DefaultView;
            pds.AllowPaging = true;
            pds.PageSize = 3;

            int currentPage = Convert.ToInt32(Request["page"]);

            pds.CurrentPageIndex = currentPage;

            pds.CurrentPageIndex = currentPage;

            if (!pds.IsFirstPage)
            {
                //lnkUp.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (currentPage - 1);
            }
            if (!pds.IsLastPage)
            {
                //lnkDown.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (currentPage + 1);
            }

            //lbl_info.Text = "第" + (currentPage + 1) + "页，共" + pds.PageCount + "页";
            gbrpt.DataSource = pds;
            gbrpt.DataBind();*/
        }


        /*发表*/
        protected void lnkPublish_Click(object sender, EventArgs e)
        {
            GuestBook gb = new GuestBook();
            gb.Title = txtTitle.Text.ToString();
            gb.Author = txtUserName.Text.ToString();
            gb.Body = txtContent.Text.ToString();
            guestbookManager.publish(gb);
            dataBind();

        }


        


    }
}